{% extends 'admin/base.html' %}

{%load comm_extras %}

{% block head_soruce %}
<script type="text/javascript">
	var url = '{%url admin-hotproduct-edit-save 88888888 %}';

	function saveHotProduct(itemId){
		var re = /^[1-9]+[0-9]*]*$/;
		var index = jQuery.trim($("#index").val());
		if(index == "" || !re.test(index)){
			alert("请输入正确的排序号");
			return false;
		}
		var	data = {'index':index};
		url = url.replace('88888888', itemId);
		$.ajax({
			url: url,
			type: 'post',
			dataType: 'json',
			data:data,
			success: function(result, textStatus){
				if(result){
					if(result.success){
						window.location.href = '{%url admin-hotproduct-index%}';
					}else{
						alert(result.err_msg);
					}
				}else{
					alert('添加失败');
				}
			},
			error: function(xhr, textStatus, errorThrown){
			}
		});
	}

</script>
{% endblock %}

{% block main_content %}
	<h1>修改推荐产品--<a href="{%url admin-hotproduct-index %}">返回推荐商品管理</a></h1>
	<ul id="movie-form" class="form">
		<li>
			<img src="/static/productimgs/{{hot.item.homeimage.thumburl}}" width="50" height="50" alt="{{hot.item.title}}" style="margin-left:100px"/>
			<a target="_blank" href="{%url product-detail-info hot.item.id%}">{{hot.item.title}}</a>
		</li>
		<li>
			<label for="index">序号:</label>
            <input type="text" id="index" name="index" value="{{hot.index}}" class="inputText" />
		</li>
		<li>
			<input type="button" value="保 存" onclick="saveHotProduct({{hot.id}});"  style="margin-left:500px"/>
		</li>
	</ul>
{% endblock %}
